home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Glyph Substitutions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-18  |  1.9 KB  |  79 lines  |  [TEXT/KAHL]

  1. /****************************************************************************************************
  2.     6/96 bob    Updated #includes to support changed GX Library names.
  3.     
  4.     ©1990 - 1996  Apple Computer, Inc.
  5.     All rights reserved.
  6. ****************************************************************************************************/
  7. #include <Types.h>
  8. #include <QuickDraw.h>
  9. #include <Fonts.h>
  10. #include <Windows.h>
  11. #include <Menus.h>
  12. #include <SegLoad.h>
  13. #include <Memory.h>
  14. #include <Desk.h>
  15.  
  16. #include <GXGraphics.h>
  17. #include "GraphicsLibraries.h"
  18. #include <GXEnvironment.h>
  19.  
  20. #include <GXTypes.h>
  21. #include <GXLayout.h>
  22. #include "LayoutLibrary.h"
  23.  
  24. #include "SampleInterface.h"
  25.  
  26. short MyStrLen(char *x);
  27. static short MyStrLen(x)
  28. char    *x;
  29.     {
  30.     short c = 0;
  31.     while (*x++) c++;
  32.     return c;
  33.     }    /* MyStrLen */
  34.  
  35. void GlyphSubstitutions(WindowPtr sampleWindow)
  36.     {
  37.     /* Variables */
  38.     char                *myString = "infinite possibilities";
  39.     gxGlyphcode            layoutGlyphs[50];        /* will be enough... */
  40.     gxGlyphSubstitution    glyphSubst;
  41.     gxPoint                myPoint;
  42.     gxRunControls            gxRunControls;
  43.     gxShape                layout;
  44.     short                len, level = 0;
  45.     gxStyle                myStyle;
  46.     gxViewPort            aViewPort;
  47.     
  48.     /* Initialization */
  49.     
  50.     myPoint.x = ff(30);
  51.     myPoint.y = ff(50);
  52.     
  53.     aViewPort = GXNewWindowViewPort(sampleWindow);
  54.     SetDefaultViewPort(aViewPort);
  55.     
  56.     len = MyStrLen(myString);
  57.     InitializeRunControls(&gxRunControls);
  58.     
  59.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  60.     
  61.     layout = GXNewLayout(
  62.         1, &len, (void *) &myString,
  63.         1, &len, &myStyle,
  64.         1, &len, &level,
  65.         nil, &myPoint);
  66.     GXDrawShape(layout);
  67.     
  68.     GXGetLayoutGlyphs(layout, layoutGlyphs, nil, nil, nil, nil, nil, nil);
  69.     glyphSubst.originalGlyph = layoutGlyphs[0];
  70.     glyphSubst.substituteGlyph = layoutGlyphs[0] + 1;
  71.     GXSetStyleRunGlyphSubstitutions(myStyle, 1, &glyphSubst);
  72.     GXMoveShape(layout, 0, ff(75));
  73.     GXDrawShape(layout);
  74.     
  75.     GXDisposeShape(layout);
  76.     GXDisposeStyle(myStyle);
  77.     GXDisposeViewPort(aViewPort);
  78.     }    /* main */
  79.